home *** CD-ROM | disk | FTP | other *** search
Wrap
Text File | 1992-11-18 | 42.0 KB | 1,112 lines | [ TEXT/MPS ]
C.S.M.P. Digest Tue, 07 Apr 92 Volume 1 : Issue 42 Today's Topics: Offscreen drawing Scrolling Windows in ThinkPascal Resorcerer vs. ResEdit How to Make Scrolling Lists in Dialogs Trouble with BitSET in THINK Pascal 4.0 X-10 Homewire interface questions Shutdown Finder Event... Subclassing CPanorama - How to get scrollbars? The Comp.Sys.Mac.Programmer Digest is moderated by Michael A. Kelly. These digests are available (by using FTP, account anonymous, your email address as password) in the pub/mac/csmp-digest directory on ftp.cs.uoregon. edu. This is also the home of the comp.sys.mac.programmer Frequently Asked Questions list. These digests are also available via email. Just send a note saying that you want to be on the digest mailing list to mkelly@cs.uoregon.edu, and you will automatically receive each new digest as it is created. The articles in these digests are taken directly from comp.sys.mac.programmer. They are not edited; all articles included in this digest are in their original posted form. The only articles that are -not- included in these digests are those which didn't receive any replies (except those that give information rather than ask a question). All replies to each article are concatenated onto the original article in the order in which they were received. Article threads are not added to the digests until the last article added to the thread is at least one month old (this is to ensure that the thread is dead before adding it to the digests). Send administrative mail to mkelly@cs.uoregon.edu. ------------------------------------------------------- From: palais@binah.cc.brandeis.edu Subject: Offscreen drawing Date: 19 Feb 92 14:20:33 GMT Organization: Brandeis University I am updating an old (Think Pascal 1.0) graphics program. Aside from converting it from a procedural to an OOP based design (I'm using AppMaker with the TCL) the main real changes are that I'll be using color and I'll be doing my drawing into an offscreen pixmap rather than directly to the graphics window. After learning about GWorlds it seemed that was clearly the way to go in order to create and maintain the offscreen pixmap. But then suddenly I realized that there was an apparently much simpler method. Since nobody seems to mention it I suppose it must have some flaw, and I wonder if anyone here can point it out to me. The idea, quite simply, is to create a clone of my graphics window, make it (and keep it) hidden, and use ITS pixmap as my offscreen drawing canvas from which I do CopyBits to my graphics window when I need to update it. - ------------------------- From: d88-jwa@hemul.nada.kth.se (Jon W{tte) Subject: Offscreen drawing Date: 20 Feb 92 09:38:22 GMT Organization: Royal Institute of Technology, Stockholm, Sweden .cs.brandeis.edu> palais@binah.cc.brandeis.edu writes: The idea, quite simply, is to create a clone of my graphics window, make it (and keep it) hidden, and use ITS pixmap as my offscreen drawing canvas from which I do CopyBits to my graphics window when I need to update it. Windows don't have their own PixMaps; they just share the screen's pixMap, with clipping. You "hide" a window by setting its clipping to "clip all." -- This Signature is distributed under the conditions of the Signature License, available at a fee from h+@nada.kth.se (Jon W{tte) Reading the Signature implies that you accept to be bound by the terms in said License. Should you not agree on any of these terms, you must return the Signature unread to me. - ------------------------- From: bakker@fwi.uva.nl (Harry Bakker (I87)) Date: 5 Mar 92 14:44:24 GMT Organization: FWI, University of Amsterdam Hello net-trekkers, I'm using a Mac LC, 4 MB internal and 40 MB external memory, and System 7.0 installed. Recently I tried to create an offscreen grafPort using the NewGWorld call and flag noNewDevice set. I just needed the grafPort and not a completely new device, since I'm working with one screen anyway (I know, I know, this is not according to Apple guidelines but is a lot simpler). After creation, I drew a picture on it, en from there CopyBits it to an onscreen window. What I got on the screen didn't look remotely at the picture I hoped I would see. Now the problem with offscreen windows is... that you can't see what's on them. What I would like is some advice of somebody, which explains how I can create an offscreen grafPort, draw a picture on it (extracted from the resource) and from there CopyBits it to an onscreen window. Preferrably in full color. Could sombody give me advice? I will be looking for replies on the Net. Thanks, H.G.Bakker, Bommerscroft 13 1902 BG Castricum The Netherlands --------------------------- From: costello@jupiter.cs.clemson.edu (E Gasparini) Subject: Scrolling Windows in ThinkPascal Organization: Clemson University Computer Science Dept. Date: Sun, 23 Feb 1992 21:06:41 GMT Hi, thanks everybody who answered my last post (a zillion years ago) My new questions are: 1. Is there a painless way of implementing scrolling windows in ThinkPascal? i.e. without using the procedures provided by the language, but rather by linking some module (TC maybe?), and avoiding code writing? 2. How can the contents of a window (incluing the hidden parts) be printed on a regular printer (image/laser writer)? From ThinkPascal again. Thanks. Please post or email your answers. ========================================================================= Elvis Gasprini costello@cs.clemson.edu - ------------------------- From: jpugh@apple.com (Jon Pugh) Date: 3 Mar 92 22:27:08 GMT Organization: Apple Co. In article <1992Feb23.210641.18107@hubcap.clemson.edu>, costello@jupiter.cs.clemson.edu (E Gasparini) writes: > > My new questions are: > 1. Is there a painless way of implementing scrolling windows in ThinkPascal? > i.e. without using the procedures provided by the language, but rather by > linking some module (TC maybe?), and avoiding code writing? > > 2. How can the contents of a window (incluing the hidden parts) be printed > on a regular printer (image/laser writer)? From ThinkPascal again. > Use the THINK Class Library. It does both of these things for you. Painless. Jon --------------------------- From: es1o+@andrew.cmu.edu (Eric Mitchell Snider) Subject: Resorcerer vs. ResEdit Date: 24 Feb 92 18:04:04 GMT Organization: Senior, Math/Computer Science, Carnegie Mellon, Pittsburgh, PA I've seen ads for Resorcerer (a resource editor as far as I know...) and I'm wondering how it compares to ResEdit. The retail price I saw was $256 so I'd like to know if it's worth it and if there's an educational discount or not. What kinds of differences are there? ResEdit does pretty much everything I need to, although it would be nice if it had a -good- balloon help editor. -Eric Snider es1o@andrew.cmu.edu - ------------------------- From: greeny@top.cis.syr.edu (Jonathan Greenfield) Subject: Resorcerer vs. ResEdit Date: 24 Feb 92 22:14:42 GMT Organization: CIS Dept., Syracuse University In article <kdeHCIe00VoxEJOEMT@andrew.cmu.edu> es1o+@andrew.cmu.edu (Eric Mitchell Snider) writes: >I've seen ads for Resorcerer (a resource editor as far as I know...) and >I'm wondering how it compares to ResEdit. The retail price I saw was >$256 so I'd like to know if it's worth it and if there's an educational >discount or not. What kinds of differences are there? ResEdit does >pretty much everything I need to, although it would be nice if it had a >-good- balloon help editor. Short of reading my mind, I can't imagine what it might do to make it worth some $200 (or even $100) to use it rather than ResEdit. Just my opinion... -- J. S. Greenfield greeny@top.cis.syr.edu (I like to put 'greeny' here, but my d*mn system wants a *real* name!) "What's the difference between an orange?" - ------------------------- From: Pete.Gontier@p811.f70.n109.z1.fidonet.org (Pete Gontier) Subject: Resorcerer vs. ResEdit Date: 29 Feb 92 16:49:25 GMT JG> From: greeny@top.cis.syr.edu (Jonathan Greenfield) JG> In article <kdeHCIe00VoxEJOEMT@andrew.cmu.edu> es1o+@andrew.cmu.edu (Eric JG> Mitchell Snider) writes: JG> >I've seen ads for Resorcerer (a resource editor as far as I know...) and JG> >I'm wondering how it compares to ResEdit. The retail price I saw was JG> >$256 so I'd like to know if it's worth it and if there's an educational JG> >discount or not. What kinds of differences are there? ResEdit does JG> >pretty much everything I need to, although it would be nice if it had a JG> >-good- balloon help editor. Resorcerer has a TMPL resource which handles balloon help. If you understand the variable-length and union-like nature of a balloon help resource, this should tell you a lot about how far superior to ResEdit Resorcerer is. (Hell, Resorcerer's balloon help editor is *usable*, which is more than I can say for BalloonWriter, which is a dedicated app.) JG> Short of reading my mind, I can't imagine what it might do to make it JG> worth some $200 (or even $100) to use it rather than ResEdit. There are quite literally dozens of reasons why you should take a look at Resorcerer. $200 is nothing, if you're actually working in the industry. There are demos posted in many places, possibly at sumex. But certainly at all the commercial BBS systems and some of the free locals. Rather than dump a list of features here, I'll merely point out that a description ought to be appearing in the FAQ for this group some time soon. - ------------------------- From: leonardr@ccs.itd.umich.edu Date: 28 Feb 92 18:07:30 GMT Organization: Campus Computing Sites, University of Michigan-Ann Arbor In article <1992Feb24.171442.2440@newstand.syr.edu> greeny@top.cis.syr.edu (Jonathan Greenfield) writes: >In article <kdeHCIe00VoxEJOEMT@andrew.cmu.edu> es1o+@andrew.cmu.edu (Eric Mitchell Snider) writes: >>I've seen ads for Resorcerer (a resource editor as far as I know...) and >>I'm wondering how it compares to ResEdit. The retail price I saw was >>$256 so I'd like to know if it's worth it and if there's an educational >>discount or not. What kinds of differences are there? ResEdit does >>pretty much everything I need to, although it would be nice if it had a >>-good- balloon help editor. > >Short of reading my mind, I can't imagine what it might do to make it >worth some $200 (or even $100) to use it rather than ResEdit. > If you just edit resources as a hobby, then I would agree that there is little reason to purcharse Resorcerer - however for those of us who spend our lives (it feels that way sometimes) editing resource it is WELL WORTH the $$. I've been using Resorcerer since it was first available as "beta-ware" almost 2 years ago (has it really been that long??) and some of the features that I can't live without including: Search & Replace: I frequently forget which resource has the data that I need (especially true of dialogs & STR#'s), and a quick search will turn up what I need. Dialog Editor: Most of the features of the ResEdit 2.x one came from their looking at Resorcerer, but Resorcerer goes even further with such additions as "Try Out" and "Generate Code" including handling of popUps and lists in both modal & modeless form! Also, this editor handles nrct's for you cdev writers. Printing: You can print ANY resource (dialogs come out very nicely) to the printer or to a text file (useful for things liek string lists). Rez Decompiler: Every resource can be "copied" to the clipboard as "Rez" source. I love this as I can edito my resources graphically in Resorcerer and then just Copy - switch to MPW -a nd paste into my .r file! TMPL editor: Makes creating you own TMPL's MUCH easier than ReEdit as well as extending the TMPL structures so that you can do some pretty cool TMPL's including "cases". And there is a LOT more that I didn't mention. The only thing that I still use ResEdit for is "bitmap" resources (icons, sicns, etc.) since ResEdit does have a better set of tools for those items. - -- - ----------------------------------------------------------------------- Leonard Rosenthol Internet: leonardr@ccs.itd.umich.edu Director of Advanced Technology AppleLink: MACgician Aladdin Systems, inc. GEnie: MACgician --------------------------- From: leue@galen.crd.ge.com (Bill Leue) Subject: How to Make Scrolling Lists in Dialogs Date: 24 Feb 92 18:43:18 GMT Organization: General Electric Research & Development I'm sorry if this subject has been rehashed 10**6 times already. I DID look through the programmer's FAQ, TechNotes, and IM before asking, but couldn't find anything. I'd like to know if anyone has come up with a "clean" way of implementing scrolling lists in a Dialog, particularly a non-modal Dialog. The built-in Dialog items that ResEdit knows about for building DITL's don't include scrolling lists of any kind. However, things like SFGetFile() use them, so obviously they're possible. In fact, my real requirements are a bit harder, since I want a) a horizontally scrolling list, and b) graphics (not text or mere icons) as list elements. However, if I could see an example of ANY kind of scrolling list and see how the controls interact with the Dialog Manager, I could probably (?) figure out the rest. Thanks! -Bill Leue leue@crd.ge.com - ------------------------- From: keith@Apple.COM (Keith Rollin) Subject: How to Make Scrolling Lists in Dialogs Date: 25 Feb 92 04:16:22 GMT Organization: Apple Computer Inc., Cupertino, CA In article <27643@crdgw1.crd.ge.com> leue@galen.crd.ge.com writes: >I'm sorry if this subject has been rehashed 10**6 times already. I DID look >through the programmer's FAQ, TechNotes, and IM before asking, but couldn't >find anything. Ahh...but you didn't look at the DTS Sample Code! >I'd like to know if anyone has come up with a "clean" way of implementing >scrolling lists in a Dialog, particularly a non-modal Dialog. The built-in >Dialog items that ResEdit knows about for building DITL's don't include >scrolling lists of any kind. However, things like SFGetFile() use them, so >obviously they're possible. DTS Sample Code #21 shows how to do this for modal dialogs. The technique for putting lists into modeless dialogs is simple to figure out from that. You can ftp the sample from ftp.apple.com. It's in the folder dts/mac/sc. >In fact, my real requirements are a bit harder, since I want a) a horizontally >scrolling list, and b) graphics (not text or mere icons) as list elements. >However, if I could see an example of ANY kind of scrolling list and see how >the controls interact with the Dialog Manager, I could probably (?) figure >out the rest. Scrolling is simple: it's supported by the List Manager when you call LClick. For instance, after you detect a mouse down even, execute something like the following: switch (event->what) { case mouseDown: localMouse = event->where; GlobalToLocal(&localMouse); bounds = GetItemRect(dlg, kPermListUser); if (PtInRect(localMouse, &bounds)) { LClick(localMouse, event->modifiers, myList); } break; (GetItemRect is a small utility function that calls GetDItem and returns the bounding rectangle. kPermListUser is the item number of the user item that is used to display the list.) Showing graphics in your list requires that you write your own LDEF, which is also very simple. Almost all you have to do is write the routine that draws a cell, given its cell number and location. -- - ---------------------------------------------------------------------------- Keith Rollin --- <Taligent .signature under construction> Disclaimer: Pretty soon, I really _won't_ be speaking for Apple... - ------------------------- From: Carl.Constantine@BCSystems.GOV.BC.CA Subject: How to Make Scrolling Lists in Dialogs Date: 26 Feb 92 21:51:03 GMT Organization: BC Systems Corporation In article <27643@crdgw1.crd.ge.com>, leue@galen.crd.ge.com (Bill Leue) writes: > I'm sorry if this subject has been rehashed 10**6 times already. I DID look > through the programmer's FAQ, TechNotes, and IM before asking, but couldn't > find anything. > > I'd like to know if anyone has come up with a "clean" way of implementing > scrolling lists in a Dialog, particularly a non-modal Dialog. The built-in > Dialog items that ResEdit knows about for building DITL's don't include > scrolling lists of any kind. However, things like SFGetFile() use them, so > obviously they're possible. Yep, they are. See below > > In fact, my real requirements are a bit harder, since I want a) a horizontally > scrolling list, and b) graphics (not text or mere icons) as list elements. > However, if I could see an example of ANY kind of scrolling list and see how > the controls interact with the Dialog Manager, I could probably (?) figure > out the rest. > I implemented a scrolling list in a modless dialog for my on-line help unit. Actually, they're not to hard (I admittedly had some problems however, especially with a mouseUp which I still haven't got to work yet). In your DITL resource, at a user-item where your list should go. In your source code where you set up the list, check for a mouseDown in your userItem (whatever ItemHit returns). From here, you can use the List Manager's routines to track the mouse in the List(userItem). Like I said. One thing I haven't been able to get to work is say you click on one item, holding the mouse button down, scroll (the List Manager takes care of this for you) to another item and let the mouse button up (mouseUp event). Technically the item the the mouse came up on should appear in my help window, but it doesn't. The item that the mouse was orignally clicked on does. I'm calling all of the mouse tracking routines and haven't been able to get this to work. (LClick, etc) any one else out there with suggestions?? I don't mean to diapoint you, but I hope that this gives you good start at any rate. -- Carl.Constantine@BCSystems.gov.bc.ca Victoria, British Columbia, Canada - ------------------------- From: ktyra@saphire (Kristopher L. Tyra) Subject: How to Make Scrolling Lists in Dialogs Date: 29 Feb 92 03:43:48 GMT Organization: The Saphire Group >(GetItemRect is a small utility function that calls GetDItem and >returns the bounding rectangle. kPermListUser is the item number >of the user item that is used to display the list.) > >Showing graphics in your list requires that you write your own LDEF, >which is also very simple. Almost all you have to do is write the >routine that draws a cell, given its cell number and location. > OH THANK GOD ITS EASY FOR SOMEONE. I'm having a terrible time with the LDEFs. First thing - I'm using a A/UX hybird g++ this all works so I don't need help there. What I don't understand is how do you get code in the resource fork! Or better yet AddResource() states that you can make a resource. So I did! NOT! ResError returned -111 some problem with zones. This is what I'm trying to do. extern void pascal_list_def(); myproc_handle = NewEmptyHandle(); *myproc_handle = pascal_list_def; AddResource(myproc_handle, 'LDEF', 128); /* Failure because AddResource didn't work. */ /* I suspect its because I have to allocate the */ /* space for the routine. ITS ALREADY THERE WHO CARES! */ If I don't do it this way how do I get the code into a resource file. I have a sneaky feeling that compiling a .o and then including won't work. HELP HELP HELP! ________________________________ Kristopher L. Tyra Consultant - A/UX, OSF, AIX/ESA (919) 481-9052 wolves!saphire!ktyra@cs.duke.edu ktyra%saphire%wolves@cs.duke.edu - ------------------------- From: dougm@descartes.cns.caltech.edu (Doug McNaught) Subject: How to Make Scrolling Lists in Dialogs Date: 1 Mar 92 07:53:07 GMT Organization: California Institute of Technology In article <1992Feb29.034348.4238@saphire> ktyra@saphire (Kristopher L. Tyra) writes: >> [deleted] >>Showing graphics in your list requires that you write your own LDEF, >>which is also very simple. Almost all you have to do is write the >>routine that draws a cell, given its cell number and location. >> > >OH THANK GOD ITS EASY FOR SOMEONE. I'm having a terrible time with >the LDEFs. First thing - I'm using a A/UX hybird g++ this all works so >I don't need help there. What I don't understand is how do you get code >in the resource fork! Or better yet AddResource() states that you can >make a resource. So I did! NOT! ResError returned -111 some problem >with zones. This is what I'm trying to do. > > > extern void pascal_list_def(); > > myproc_handle = NewEmptyHandle(); > *myproc_handle = pascal_list_def; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This, in the immortal words of MacTutor, is a "dangerous evil mutant method" of creating a code resource. Aiming the master pointer of an existing resource at a routine in your code (which is part of a CODE resource itself) is going to confuse the hell out of the Memory Manager. If whoever ported your g++ did a decent job, there should be some kind of switch to tell it to compile a single function as a code resource. If not, I *suppose* you could hack something up using BlockMove() to copy your routine's code into a handle, or use the tried- and-true 'six-byte resource' technique, which under A/UX requires that you flush the processor's caches. The 'six-byte resource' is an LDEF resource which contains an absolute JMP instruction in the first two bytes and the address of your procedure in the last four. I've never done it under A/UX so am a bit foggy on when and how the cache needs to be flushed--maybe one of the Quadra types out there could help out? > AddResource(myproc_handle, 'LDEF', 128); > > /* Failure because AddResource didn't work. */ > /* I suspect its because I have to allocate the */ > /* space for the routine. ITS ALREADY THERE WHO CARES! */ > > >If I don't do it this way how do I get the code into a resource file. I >have a sneaky feeling that compiling a .o and then including won't work. Probably not. Sorry I can't help you on this bit. regards, doug -- <><><><><><><><><><><><><><><>Go Skins!!<><><><><><><><><><><><><><><><> <> Doug McNaught dougm@descartes.caltech.edu <> <> Help!!! I'm addicted to *Spaceward Ho!* Is there a support group? <> <><><><><><><><><><><><><><><>Go Skins!!<><><><><><><><><><><><><><><><> - ------------------------- From: ktyra@saphire (Kristopher L. Tyra) Date: 4 Mar 92 23:28:59 GMT Organization: The Saphire Group In article <1992Mar1.075307.6197@cco.caltech.edu> dougm@descartes.cns.caltech.edu (Doug McNaught) writes: >> >> extern void pascal_list_def(); >> >> myproc_handle = NewEmptyHandle(); >> *myproc_handle = pascal_list_def; > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ > This, in the immortal words of MacTutor, is a "dangerous evil mutant method" >of creating a code resource. Aiming the master pointer of an existing resource >at a routine in your code (which is part of a CODE resource itself) is going to >confuse the hell out of the Memory Manager. Boy and are you right. > If whoever ported your g++ did a >decent job, there should be some kind of switch to tell it to compile a single >function as a code resource. If not, I *suppose* you could hack something up >using BlockMove() to copy your routine's code into a handle Actually I did the port and 'decent' isn't one of the words I'd use. How about mutilated! (G++ 1.xx not 2.0 I haven't tried out Johns new stuff yet). >, or use the tried- >and-true 'six-byte resource' technique, which under A/UX requires that you >flush the processor's caches. The 'six-byte resource' is an LDEF resource which >contains an absolute JMP instruction in the first two bytes and the address of >your procedure in the last four. I've never done it under A/UX so am a bit >foggy on when and how the cache needs to be flushed--maybe one of the Quadra >types out there could help out? This is what I eventually found out by looking at some code that tested the LDEF's. I forget the author write off hand but he built a jmp instruction type resource and all is well. However, I didn't flush the cache. I haven't had any problems (Racer 030 33mhz with external cache). Could some one expand on this a bit? Thanks to everyone for there help! ________________________________ Kristopher L. Tyra Consultant - A/UX, OSF, AIX/ESA (919) 481-9052 wolves!saphire!ktyra@cs.duke.edu ktyra%saphire%wolves@cs.duke.edu --------------------------- From: felciano@medisg.stanford.edu (Ramon Felciano) Subject: Trouble with BitSET in THINK Pascal 4.0 Organization: SUMMIT, Stanford U. Medical Media & Information Technologies Date: Tue, 25 Feb 92 18:13:45 GMT Hello! I'm writing an MDEF and am struggling with the enabled flags of the menu resource. The problem seems to resolve around how to get and set bits. I've run into this before, specifically when checking the result returned from the Gestalt manager. Here's an simple example: PROGRAM Dummy; TYPE Bits = PACKED ARRAY[0..31] OF boolean; VAR MyFlags: longint; Loop: integer; BEGIN MyFlags := 0; FOR Loop := 0 TO 31 DO BitSET(@MyFlags, Loop); END. Ordinarily, I would assume that this would loop through 32 times, setting the bits of MyFlags from right (0) to left (31). If I set a checkpoint at the BitSET line, and typecast MyFlags to Bits (as defined above), I can use Lightsbug to view MyFlags as a series of booleans (the closest thing to a bit readout I could think of). When I do so, I see weird things happening. The loop does set the bits of my flags, but starts at array position 7, then works down to 0, then jumps to around 14, working down to 8, then up to 21, etc. Whaaaaaaaaa? Any ideas on how this is solved? And I right in interpreting the following code (see code comments): MyFlags := 0; {MyFlags is 0} BitSET(@MyFlags, 0); {MyFlags is 1} MyFlags := 0; {MyFlags is 0} BitSET(@MyFlags, 1); {MyFlags is 2} MyFlags := 0; {MyFlags is 0} BitSET(@MyFlags, 0); {MyFlags is 1} BitSET(@MyFlags, 1); {MyFlags is 3} Thank you in advance! Ramon M. Felciano Associate Director, SUMMIT Stanford University Medical Media and Information Technologies P.S. Please feel free to answer via e-mail in order to avoid net clutter. (I'm at felciano@medisg.stanford.edu) - ------------------------- From: REEKES@applelink.apple.com (Jim Reekes) Date: 3 Mar 92 22:48:21 GMT Organization: Apple Computer, Inc. In article <1992Feb25.181345.20483@leland.Stanford.EDU>, felciano@medisg.stanford.edu (Ramon Felciano) writes: > I'm writing an MDEF and am struggling with the enabled flags of the > menu resource. The problem seems to resolve around how to get and > set bits. I've run into this before, specifically when checking the > result returned from the Gestalt manager. > (example code calling BitSet...) Here's some example code for setting, clearing, and testing bits in Pascal. PROCEDURE TestBits(myFlags : LONGINT); CONST kFlagZero = $1; kFlagOne = $2; kFlagTwo = $4; kFlagNotZero = $FFFFFFFE; kFlagNotOne = $FFFFFFFD; kFlagNotTwo = $FFFFFFFB; BEGIN myFlags := BOr(myFlags, kFlagZero); {this sets bit zero} myFlags := BOr(myFlags, kFlagOne); {this sets bit one} myFlags := BOr(myFlags, kFlagTwo); {this sets bit two} {this sets bits zero, one, and two} myFlags := BOr(myFlags, kFlagZero+kFlagOne+kFlagTwo); myFlags := BAnd(myFlags, kFlagNotZero); {this clears bit zero} myFlags := BAnd(myFlags, kFlagNotOne); {this clears bit one} myFlags := BAnd(myFlags, kFlagNotTwo); {this clears bit two} {this clears bits zero, one, and two} myFlags := BAnd(myFlags, BNot(kFlagZero+kFlagOne+kFlagTwo)); IF BAnd(myFlags, kFlagZero) <> 0 THEN {this tests if bit zero is set} ; IF BAnd(myFlags, kFlagOne) <> 0 THEN {this tests if bit one is set} ; IF BAnd(myFlags, kFlagTwo) <> 0 THEN {this tests if bit two is set} ; {this tests if bits zero, one, and two are set} IF BAnd(myFlags, kFlagZero+kFlagOne+kFlagTwo) <> 0 THEN ; END; Here's the object code generated for the above MPW Pascal source. LINK A6,#$0000 MOVE.L D7,-(A7) MOVE.L $0008(A6),D7 OR.L #$00000001,D7 ;this sets bit zero OR.L #$00000002,D7 ;this sets bit one OR.L #$00000004,D7 ;this sets bit two MOVEQ #$00,D0 MOVE.W #$0007,D0 OR.L D0,D7 ;this sets bits zero, one, and two AND.L #$FFFFFFFE,D7 ;this clears bit zero AND.L #$FFFFFFFD,D7 ;this clears bit one AND.L #$FFFFFFFB,D7 ;this clears bit two MOVEQ #$00,D0 MOVE.W #$0007,D0 NOT.L D0 AND.L D0,D7 ;this clears bits zero, one, and two MOVE.L D7,D0 AND.L #$00000001,D0 TST.L D0 ;this tests if bit zero is set MOVE.L D7,D0 AND.L #$00000002,D0 TST.L D0 ;this tests if bit one is set MOVE.L D7,D0 AND.L #$00000004,D0 TST.L D0 ;this tests if bit two is set MOVEQ #$00,D0 MOVE.W #$0007,D0 MOVE.L D7,D1 AND.L D0,D1 TST.L D1 ;this tests if bits zero, one, and two are set MOVE.L (A7)+,D7 UNLK A6 MOVE.L (A7)+,(A7) RTS This is a features of the MPW Pascal compiler and it translates into a single assembly instruction as shown. I'm certain that the LS Pascal compiler will support this too, since MacApp probably used it. It's stupid to call a trap just to set a bit. You do have to be careful when testing or clearing multiple bits since Pascal does not have a bitwise NOT operator. In C and Assembly you can use ~kFlagOne instead of the special constant kFlagNotOne. And since you cannot sum all of the kFlagNotxxx constants together to create the proper mask when testing for multiple bits, I used the BNot instruction to perform the twos compliment at runtime. You could have other masks defined for special bit patterns. - ------------------------------------------------------------------- Jim Reekes, E.O. | Macintosh Toolbox Engineering | Sound Manager Expert Apple Computer, Inc. | All opinions expressed are mine, and 20525 Mariani Ave. MS: 81-EQ | do not necessarily represent those Cupertino, CA 95014 | of my employer, Apple Computer Inc. --------------------------- From: mstephens.520@postman.gsfc.nasa.gov (mark stephens) Subject: X-10 Homewire interface questions Date: 25 Feb 92 20:57:38 GMT Organization: nasa/gsfc Hi folks, I will soon have the Mac version of the x-10 interface kit. X-10 is a hardware/protocol which allows electrical appliances to be turned off and on via signals sent in electrical wiring. I'll mainly use it for controlling devices connected to aquarium and plant lights. I plan to program the device via a Mac IIsi and, if possible, have a MacPlus control the devices on a continuous bases. Does anybody have any experience with this device? Does anybody have a HyperCard or other interface? I'm hoping it comes with one, but I'm assuming it comes with a set of serial port commands and some hoky, PC based interface. Hope I'm wrong! thanks, mark - ------------------------- From: stevens@sigi.cs.colorado.edu (Curt Stevens) Subject: X-10 Homewire interface questions Date: 27 Feb 92 20:58:54 GMT Organization: University of Colorado, Boulder In article <1992Feb25.205738.2524@kong.gsfc.nasa.gov> mstephens.520@postman.gsfc.nasa.gov (mark stephens) writes: >Hi folks, > >I will soon have the Mac version of the x-10 interface kit. X-10 is a >hardware/protocol which allows electrical appliances to be turned off and >on via signals sent in electrical wiring. I'll mainly use it for controlling >devices connected to aquarium and plant lights. I plan to program the device >via a Mac IIsi and, if possible, have a MacPlus control the devices on a >continuous bases. X-10's Mac interface includes an application and a box to download X-10 instructions so that your Mac does NOT have to be on in order to have your programs running. This external box uses a serial connection and allows you to download instructions, turn your computer off, and continue to have your X-10 programs run. X-10 also supplies you with the protocol so that you can write your own applications or stacks to control your lights. > >Does anybody have any experience with this device? My entire household is wired to X-10 devices. My favorite thing about the system is that you can purchase IR-remotes to control everything. I can turn on/off/dim any light in my house from my seat in front of the TV. This comes in really handy when you go to sleep and forget to turn off some lights (there is an "all lights off" button on the remotes). Also, I live in the cold and I can use the remote to turn on my bathroom heater a few minutes before getting out of bed in the morning. If you are getting the idea that I am lazy, you are absolutely correct :->. X-10 makes it all that much easier. Another thing I do with it is set the "box" to run lights when I am away. You can write a program (by clicking on icons etc.) that will run you lights in a pattern similar to that which you would exhibit if you were really home. There is even a security feature that varies light commands by +/-20 minutes randomly so that your lights don't do exactly the same thing every night you are away. There are also modules to control home thermostats (I don't have this one!), lamps (two-prong plugs), appliances (three-prong plugs), flourescent lamps, etc. >Does anybody have a HyperCard or other interface? Im hoping it comes with one, >but I'm assuming it comes with a set of serial port commands and some >hoky, PC based interface. Hope I'm wrong! The version for the Mac is iconic and reasonable. The PC version is hoky and disgusting. ======================================================================== |Curt Stevens (303) 492-1218 | / |arpa:stevens@sigi.cs.colorado.edu | |Univ. of Colorado, Boulder |o o|uucp:ncar!sigi.cs.colordo.edu!{...}| |Computer Sci. Dept. ECOT 7-7 | | |-----------------------------------| |Campus Box 430 |\_/| I contradict myself? Very well, I | |Boulder, Colorado 80309 USA | | contradict myself. - Walt Whitman | ======================================================================== -- ======== | Curt | ======== - ------------------------- From: stevens@sigi.cs.colorado.edu (Curt Stevens) Subject: X-10 Homewire interface questions Date: 29 Feb 92 19:04:13 GMT Organization: University of Colorado, Boulder In article <1992Feb27.205854.6504@colorado.edu> stevens@sigi.cs.colorado.edu (Curt Stevens) writes: >>My entire household is wired to X-10 devices. > >How much did this cost you? I don't want specifics, just approximate costs >of boxes. I'm interested in doing the _exact_ same thing, but I >was concerned I would have to leave my Mac turned on all night >(as if it's not already!). > >Glad to hear it works! I certainly does! As for how much this costs; each lamp, appliance, and wall switch module costs about $12.00 at radio shack. 3-Way wall switches cost a bit more (these are for lights controlled by two wall switches instead of the standard single control). I have absolutely NO idea how much the serial computer interface costs (I purchased it many years ago). It utilizes an RS-232 connection and operates perfectly with my modem cable. You only need to connect the interface to your Mac when you are downloading programs from the X-10 software. Therefore, you can temporarily connect your modem cable to the X-10 box, download your programs (you must connect before launching the X-10 software), and reconnect the cable to your modem. You can then turn off your computer because the interface holds the program. The interface plugs into the wall (just like lamp and appliance modules) and contains a 9-volt battery for backup in case of power failure. For more information you can contact: X-10(USA) INC. 185A Legrand Ave. Northvale, NJ 07647 (201) 784-9700 and ask about: X-10 Powerhouse RS-232 Computer Interface (specify Mac or IBM) (My model number for the Mac [remember my unit is very old] is Model CP290) ======================================================================== |Curt Stevens (303) 492-1218 | / |arpa:stevens@sigi.cs.colorado.edu | |Univ. of Colorado, Boulder |o o|uucp:ncar!sigi.cs.colordo.edu!{...}| |Computer Sci. Dept. ECOT 7-7 | | |-----------------------------------| |Campus Box 430 |\_/| I contradict myself? Very well, I | |Boulder, Colorado 80309 USA | | contradict myself. - Walt Whitman | ======================================================================== -- ======== | Curt | ======== - ------------------------- From: jpugh@apple.com (Jon Pugh) Subject: X-10 Homewire interface questions Date: 3 Mar 92 00:08:07 GMT Organization: Apple Co. In article <1992Feb25.205738.2524@kong.gsfc.nasa.gov>, mstephens.520@postman.gsfc.nasa.gov (mark stephens) writes: > > I will soon have the Mac version of the x-10 interface kit. X-10 is a > hardware/protocol which allows electrical appliances to be turned off and > on via signals sent in electrical wiring. I'll mainly use it for controlling > devices connected to aquarium and plant lights. I plan to program the device > via a Mac IIsi and, if possible, have a MacPlus control the devices on a > continuous bases. > > Does anybody have any experience with this device? > > Does anybody have a HyperCard or other interface? I'm hoping it comes with one, > but I'm assuming it comes with a set of serial port commands and some > hoky, PC based interface. Hope I'm wrong! It comes with a hokey Macintosh interface. Hardly better. It crashes regularly and has not been updated since 1987 or so. Once you get it set up however, it runs like a champ. I have been using it for years and like it. I have played with a Hypercard interface but this is not the best choice since HC canUt deal with Nulls and the interface uses them. I have been thinking about writing an XCMD to do all the io but havenUt had the time. If I move I will probably do this since the software wonUt run on my Quadra any more and I will need to set it up for my new house. Until then I just leave it alone. Jon - ------------------------- From: mandel@vax.anes.tulane.edu (Jeff E Mandel) Date: 4 Mar 92 18:48:44 GMT Organization: Tulane University School of Medicine In article <21007@goofy.Apple.COM> jpugh@apple.com (Jon Pugh) writes: >I have been thinking about writing an XCMD to do all the io but >havenUt had the time. If I move I will probably do this since the software >wonUt run on my Quadra any more and I will need to set it up for my new house. >Until then I just leave it alone. I trust we can ultimately look forward to a set of X-10 AppleEvents? Jeff E Mandel MD MS Associate Professor of Anesthesiology Tulane University School of Medicine New Orleans, LA mandel@vax.anes.tulane.edu --------------------------- From: danny@utkux1.utk.edu (Danny McCampbell) Subject: Shutdown Finder Event... Date: 26 Feb 92 20:26:40 GMT Organization: University of Tennessee Is there an easy way to send the Shutdown event to the Finder from an application? I have a modal dialog with two buttons. If the user clicks on one something happens, but if they click on the other one I want the Mac to shutdown. Please, any help would be appreciated. I am new to this stuff. Danny - ------------------------- From: jpugh@apple.com (Jon Pugh) Date: 3 Mar 92 22:48:40 GMT Organization: Apple Co. In article <1992Feb26.202640.25831@utkux1.utk.edu>, danny@utkux1.utk.edu (Danny McCampbell) writes: > > Is there an easy way to send the Shutdown event to the Finder from > an application? I have a modal dialog with two buttons. If the > user clicks on one something happens, but if they click on the > other one I want the Mac to shutdown. Please, any help would be > appreciated. I am new to this stuff. > > Danny For example code you can check out my FinderEvents XCMD which includes Pascal source on ftp.apple.com in /pub/pugh/hyperstuff. This is a really simple event. Jon --------------------------- From: chait@cs.umass.edu Subject: Subclassing CPanorama - How to get scrollbars? Date: 26 Feb 92 22:07:51 GMT Organization: COINS, UMass, Amherst I'm hoping that there's a few people out there hot on TCL who can help me with a project I'm working on (I've got lots of Qs about TCL, but need one answer immediately). I've got a subclass of CPanorama which basically displays subpanes of Icons in rows and columns (36 pixels tall by 640 wide). I have it autoinitializing a ton of icon panes; in fact, they go off the bottom of the window. My problem is, I don't know how to set up the Panorama to 1. turn on the scroll bars (and, I guess, turn them back off) 2. have it scroll correctly when I click 3. have it autoscroll when I'm dragging icons around the panorama. If anyone can help me with this, I'd appreciate it. Let's hear it for Honors Thesis hell... Dave Chait Chief Architect Future Generation Software - ------------------------- From: jpugh@apple.com (Jon Pugh) Date: 3 Mar 92 22:47:10 GMT Organization: Apple Co. In article <44017@dime.cs.umass.edu>, chait@cs.umass.edu writes: > > I'm hoping that there's a few people out there hot on TCL who can help me with > a project I'm working on (I've got lots of Qs about TCL, but need one answer > immediately). I've got a subclass of CPanorama which basically displays > subpanes of Icons in rows and columns (36 pixels tall by 640 wide). I have > it autoinitializing a ton of icon panes; in fact, they go off the bottom of > the window. My problem is, I don't know how to set up the Panorama to > 1. turn on the scroll bars (and, I guess, turn them back off) > 2. have it scroll correctly when I click > 3. have it autoscroll when I'm dragging icons around the panorama. > Don't put this stuff in the Panaroma, put a ScrollPane there and put all your Pane subclasses in it. Jon --------------------------- End of C.S.M.P. Digest **********************